#!/bin/sh -e

export LDFLAGS="$LDFLAGS -static"

if cpt l gnutls; then
    LIBGNUTLS_CFLAGS="$(pkgconf --static --cflags gnutls)"
    LIBGNUTLS_LIBS="$(pkgconf --static --libs gnutls)"
    export LIBGNUTLS_CFLAGS LIBGNUTLS_LIBS
fi

patch -p1 < fix-ldap.patch

./configure \
    --prefix=/usr \
    --sbindir=/usr/bin

make
make DESTDIR="$1" install
